using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Tdoctran Test Class
  /// </summary>
  [TestClass]
  public class TestTdoctran
  {
    #region Class Variables
    private CdoPrms<DOTdoctran>		m_Tdoctran;
    private CdoPrmsList<DOTdoctran>	m_AllTdoctran;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestTdoctran()
    {
      // Create the data objects
      this.m_Tdoctran	= new CdoPrms<DOTdoctran>();
      this.m_AllTdoctran	= new CdoPrmsList<DOTdoctran>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Tdoctran data objects
    /// </summary>
    [TestMethod]
    public void TdoctranRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllTdoctran.DataObject = new DOTdoctran();
      this.m_AllTdoctran.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllTdoctran.PerformAction())
      {
        // Assert the errors
        if (this.m_AllTdoctran.Errors.Count > 0) { Assert.Fail(this.m_AllTdoctran.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Tdoctran
    /// </summary>
    [TestMethod]
    public void TdoctranCreate()
    {
      // Set up the data object for creation
      this.m_Tdoctran.DataObject.d_datetime = DateTime.Now;
      this.m_Tdoctran.DataObject.d_status = "Test d_status";
      this.m_Tdoctran.DataObject.d_descrip = "Test d_descrip";
      this.m_Tdoctran.DataObject.d_releasetype = "Test d_releasetype";
      this.m_Tdoctran.DataObject.d_releasereason = "Test d_releasereason";
      this.m_Tdoctran.DataObject.d_primaryattorney = "Test d_primaryattorney";
      this.m_Tdoctran.DataObject.d_secondaryattorney = "Test d_secondaryattorney";
      this.m_Tdoctran.DataObject.d_releasedate = DateTime.Now;
      this.m_Tdoctran.DataObject.d_returndate = DateTime.Now;
      this.m_Tdoctran.DataObject.d_primaryattorneyletterreference = "Test d_primaryattorneyletterreference";
      this.m_Tdoctran.DataObject.d_secondaryattorneyletterreference = "Test d_secondaryattorneyletterreference";
      this.m_Tdoctran.DataObject.d_trackingnumber = "Test d_trackingnumber";
      this.m_Tdoctran.DataObject.d_user = "Test d_user";
      this.m_Tdoctran.DataObject.d_workstation = "Test d_workstation";
      this.m_Tdoctran.DataObject.d_uniqueid = Guid.NewGuid();
      this.m_Tdoctran.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Tdoctran.PerformAction())
      {
        // Assert the errors
        if (this.m_Tdoctran.Errors.Count > 0) { Assert.Fail(this.m_Tdoctran.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Tdoctran
    /// </summary>
    [TestMethod]
    public void TdoctranRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Tdoctran.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Tdoctran.DataObject.d_id = "Test d_id";
      }

      // Set up the data object action for retrieval
      this.m_Tdoctran.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Tdoctran.PerformAction())
      {
        // Assert the errors
        if (this.m_Tdoctran.Errors.Count > 0) { Assert.Fail(this.m_Tdoctran.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
